# ---------- ---------- ---------- ---------- ---------- ----------
#
# med-fe Makefile
#
#    1) config, vars, and target
#    2) functions
#    3) phonies
#
# ---------- ---------- ---------- ---------- ---------- ----------

target: help


# ---------- ---------- ---------- ---------- ---------- ----------
# functions
# ---------- ---------- ---------- ---------- ---------- ----------

define fix
	@npx prettier --write \
            ./src/*/*.js      \
            ./src/*/*.vue     \
            babel.config.js   \
            .eslintrc.js      \
            vue.config.js
endef

define upgrade
	vue upgrade
	npm audit fix || echo ""
	@echo "Suggestion:"
	@echo "    sudo npm update -g @vue/cli"
endef

define version
	@npx genversion --es6 --semi --double src/version/index.js
endef


# ---------- ---------- ---------- ---------- ---------- ----------
# phonies
# ---------- ---------- ---------- ---------- ---------- ----------


.PHONY: help
help:
	@echo "Usage: make [PHONY]"
	@sed -n -e '/sed/! s/\.PHONY: //p' Makefile


.PHONY: build
build:
	@npm run build


.PHONY: clean
clean:
	@rm -rf dist/


.PHONY: dev
dev:
	@$(call fix)
	@$(call version)


.PHONY: rebuild
rebuild: clean build


.PHONY: rerun
rerun: dev run


.PHONY: run
run:
	@npm run serve


.PHONY: upgrade
upgrade:
	@$(call upgrade)
